<template>
  <div class="about">
    <div class="my_header">
      <div class="title">MY CGV</div>
 


      <div class="btm" v-if="isLogin"  @click="$router.push('/userInfo')">
      <!-- 登录的状态 -->
        <div class="head_portrait">
          <img :src="$root.userInfo.avatar||require('@/assets/photo.png')" alt />
        </div>
        <div class="center">
          <div class="name">
            <span>{{$root.userInfo.nickname||'小莱影迷'}}</span>
              <van-icon name="edit" />
          </div>
          <div class="msg">
           <van-icon name="like-o" />
            <span>初心朋友</span>|
           <van-icon name="todo-list-o" />
            <span>可用积分:5</span>
          </div>
        </div>
        <div class="qr_code">
        <van-icon name="qr" />
        </div>
      </div>

      <div class="btm" v-else @click="$router.push('/login')">
      <!-- 没登录的状态 -->
        <div class="head_portrait">
          <img :src="require('@/assets/photo.png')" alt />
        </div>
        <div class="center">
          <div class="name">
            <span>请登录</span>
          
          </div>

        </div>
        <!-- <div class="qr_code">
          <svg class="icon" aria-hidden="true" width="20" height="20">
            <use xlink:href="#icon-erweima-fff" />
          </svg>
        </div> -->
      </div>



    </div>
    <div class="priend">
      <div class="item">
        <div>
          <img :src="require('@/assets/pirendCrad.png')" alt />
        </div>
        <span>朋友卡</span>
      </div>
      <div class="item">
        <div>
          <img :src="require('@/assets/juan.png')" alt />
        </div>
        <span>票卷</span>
      </div>
    </div>

    <div class="list">
      <van-cell class="cell1">
        <!-- 使用 title 插槽来自定义标题 -->
        <template #title>
          <van-cell center title="我的订单" />
        </template>
        <template #right-icon>
          <van-icon center name="arrow" />
        </template>
        <template #icon>
          <svg class="icon" aria-hidden="true" width="30" height="30">
            <use xlink:href="#icon-dingdan" />
          </svg>
        </template>
      </van-cell>
      <van-cell class="cell1">
        <template #title>
          <van-cell center title="我的积分" />
        </template>
        <template #right-icon>
          <van-icon center name="arrow" />
        </template>
        <template #icon>
          <svg class="icon" aria-hidden="true" width="30" height="30">
            <use xlink:href="#icon-jifen" />
          </svg>
        </template>
      </van-cell>
      <van-cell class="cell1">
        <template #title>
          <van-cell center title="想看列表" />
        </template>
        <template #right-icon>
          <van-icon center name="arrow" />
        </template>
        <template #icon>
          <svg class="icon" aria-hidden="true" width="30" height="30">
            <use xlink:href="#icon-aixin1" />
          </svg>
        </template>
      </van-cell>
      <van-cell class="cell1">
        <!-- 使用 title 插槽来自定义标题 -->
        <template #title>
          <van-cell center title="我的二维码" />
        </template>
        <template #right-icon>
          <van-icon center name="arrow" />
        </template>
        <template #icon>
          <svg class="icon" aria-hidden="true" width="30" height="30">
            <use xlink:href="#icon-erweima" />
          </svg>
        </template>
      </van-cell>
      <van-cell class="cell1">
        <!-- 使用 title 插槽来自定义标题 -->
        <template #title>
          <van-cell center title="常见观影人" />
        </template>
        <template #right-icon>
          <van-icon center name="arrow" />
        </template>
        <template #icon>
          <svg class="icon" aria-hidden="true" width="30" height="30">
            <use xlink:href="#icon-lianxiren" />
          </svg>
        </template>
      </van-cell>
      <van-cell class="cell1">
        <!-- 使用 title 插槽来自定义标题 -->
        <template #title>
          <van-cell center title="客服" />
        </template>
        <template #right-icon>
          <van-icon center name="arrow" />
        </template>
        <template #icon>
          <svg class="icon" aria-hidden="true" width="30" height="30">
            <use xlink:href="#icon-kefu" />
          </svg>
        </template>
      </van-cell>
    </div>
    <div class="log_out" v-if="isLogin" @click="logout">退出登录</div>
   
  </div>
</template>

<script>
import { Cell, CellGroup, Icon } from 'vant'

export default {
  name: 'WorkspaceJsonMine',
  components: {
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
    [Icon.name]: Icon,
  },
  data() {
    return {

    }
  },
  computed:{
     isLogin(){
       return this.$root.token&&this.$root.uid
     } 
  },

  created() {



  },

  methods: {
    
    logout(){
      this.$dialog.confirm({
        title:"提示",
        message:"您确定要退出当前账号吗?"
      }).then(res=>{
        
             localStorage.removeItem('xl-token')
              localStorage.removeItem('xl-tokenExpired')
              localStorage.removeItem('xl-uid')
              localStorage.removeItem('xl-userInfo')

              this.$root.token = '';
              this.$root.uid = ''
              this.$root.userInfo = {}

      }).catch(err=>{
        console.log(err)
      })
    }


  },
}
</script>


<style lang="less" scoped>
.about {
  background-color: #f8f8f8;
  .my_header {
    background-color: @color;
    color: #fff;
    .title {
      position: fixed;
      top: 0;
      z-index: 33;
      width: 100%;
      background-color:@color;
      height: 46px;
      line-height: 46px;
      color: #fff;
      text-align: center;
    }
    .btm {
      margin-top: 46px;
      padding: 35px 15px;
      display: flex;
      justify-content: flex-start;
      align-items: flex-start;
      height: 90px;
      .head_portrait {
        width: 90px;
        height: 90px;
        border-radius: 50%;
        overflow: hidden;
        border: 1px solid #ccc;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .center {
        height: inherit;
        display: flex;
        flex-direction: column;
        padding: 3px 0;
        box-sizing: border-box;
        justify-content: space-between;
        .name {
          display: flex;
          align-items: center;
          span {
            font-size: 22px;
            margin-right: 5px;
          }
        }
        .msg {
          display: flex;
          align-items: center;
          svg {
            margin: 0 5px;
          }
          span {
            margin: 0 5px;
          }
        }
      }
    }
  }
  .priend {
    background-color: #fff;
    display: flex;
    padding: 30px 0;
    .item {
      display: flex;
      flex-direction: column;
      align-items: center;
      color: #333;
      justify-content: space-between;

      width: 50%;
      box-sizing: border-box;
    }
    .item:first-child {
      border-right: 1px solid #ccc;
    }
  }
  .list {
    margin-top: 15px;
    background-color: #fff;
    padding: 0 20px;
    .cell1 {
      align-items: center;
      height: 70px;
      padding-left: 0;
      padding-right: 0;
      font-size: 22px;
      color: #ccc;
      border-bottom: 1px solid #ccc;
      /deep/ span {
        font-size: 22px;
      }
    }
    .cell1:last-of-type {
      border: none;
    }
  }
  .log_out {
    margin-top: 15px;
    width: 100%;
    height: 100px;
    line-height: 100px;
    text-align: center;
    color: #333;
    font-size: 24px;
    background-color: #fff;
  }
}
</style>